 <template>
  <div class="home">
    <div class="posts">
      <div v-for="post in posts" :key="post.id" class="post-card">
        <h2>{{ post.title }}</h2>
        <div class="post-meta">
          <span class="date">{{ post.date }}</span>
          <span v-for="tag in post.tags" :key="tag" class="tag">{{ tag }}</span>
        </div>
        <p class="excerpt">{{ post.excerpt }}</p>
        <router-link :to="{ name: 'post', params: { id: post.id }}" class="read-more">
          阅读更多
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
import { computed } from 'vue'
import { useStore } from 'vuex'

export default {
  name: 'Home',
  setup() {
    const store = useStore()
    const posts = computed(() => store.state.posts.list)
    return { posts }
  }
}
</script>

<style scoped>
.home {
  padding: 20px;
}

.post-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.post-meta {
  margin: 10px 0;
  color: #666;
}

.tag {
  background: var(--primary-color);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 8px;
  font-size: 0.9em;
}

.excerpt {
  color: #666;
  margin: 10px 0;
}

.read-more {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.read-more:hover {
  text-decoration: underline;
}
</style>